Skip to content

New Feature: Support Convert to another type. - #2294

Open
frg2089 wants to merge 9 commits into
Phobos-developers:developfrom
ShimakazeProject:develop
Open

frg2089 wants to merge 9 commits into
Phobos-developers:developfrom
ShimakazeProject:develop

Conversation

@frg2089

@frg2089 frg2089 commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

What kind of change is this?

  • New feature, vanilla bugfix or enhancement of a released feature - changelog, docs and credits entries are needed.
  • Improvement to a new (unreleased) feature - docs and credits entries are needed; no changelog entry (Skip Changelog).
  • Bugfix to a new (unreleased) feature - credits entry is needed; no changelog or docs entries (Skip Changelog, Skip Docs).
  • Bugfix to an old (released) feature - changelog and credits entries are needed; no docs entry (Skip Docs).
  • Completely minor change (e.g. a typo fix) - no entries are needed (Skip Changelog, Skip Docs, Skip Credits).

Description

Type conversion now works between any two TechnoTypes, including to and from BuildingTypes.

  • Applies to warhead/SW Convert, Convert.Deploy/Undeploy, Convert.Health, Ammo.AutoConvertType, Convert.HumanToComputer/Convert.ComputerToHuman and Ares' type conversion, with building placement checks, status transfer and Convert.Direction.
  • Infantry walk to the centre of their cell before converting into a non-infantry type; unplaceable buildings refuse the deploy order.
  • New tags: Convert.ShowBuildup, Convert.ShowBuildupFrom, Convert.ShowBuildupTo, Convert.Direction, Convert.Health.AfterBuildup.
  • Docs, Whats-New, CREDITS and zh_CN .po entries included.

@frg2089 frg2089 changed the title Refactor type conversion logic to support cross-type conversion and add UndeploysInto.ConvertTo trigger New Feature: Support Convert to another type. Jul 18, 2026
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Unit/Hooks.DeploysInto.cpp Outdated
Comment thread src/Ext/Techno/Body.Update.cpp Outdated
Comment thread docs/New-or-Enhanced-Logics.md Outdated
@frg2089
frg2089 marked this pull request as draft July 18, 2026 17:38
@github-actions

github-actions Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@frg2089
frg2089 marked this pull request as ready for review July 19, 2026 02:21
Comment thread src/Ext/Techno/Body.cpp Outdated

@TaranDahl TaranDahl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no other issues.

@TaranDahl TaranDahl added Needs testing ⚙️T1 T1 maintainer review is sufficient labels Jul 23, 2026
@TaranDahl
TaranDahl requested a review from NetsuNegi July 23, 2026 10:27
@frg2089

frg2089 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

喵?

@TaranDahl

Copy link
Copy Markdown
Contributor

喵?

Since this is your first PR submission, your code will need reviews from more maintainers before it can be merged. This is the rule of Phobos.

@frg2089

frg2089 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

Since this is your first PR submission, your code will need reviews from more maintainers before it can be merged. This is the rule of Phobos.

OK, I will stop resolving the conflict before there are further results.

@frg2089
frg2089 deleted the branch Phobos-developers:develop August 23, 2026 04:15
@frg2089 frg2089 closed this Aug 23, 2026
@frg2089
frg2089 deleted the develop branch August 23, 2026 04:15
@frg2089
frg2089 restored the develop branch August 23, 2026 04:17
@frg2089 frg2089 reopened this Aug 23, 2026
Copilot AI lite review requested due to automatic review settings August 23, 2026 04:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors Phobos’ TechnoType conversion pipeline to support cross-category conversions (object replacement) across Infantry/Unit/Building types, adds a new BuildingType INI trigger (UndeploysInto.ConvertTo) to convert the undeployed unit on the next frame, and updates documentation/changelog/credits accordingly.

Changes:

  • Added cross-category conversion via TechnoExt::ConvertToTypeEx (create new object + destroy old), with deferred conversion support (PendingConvertTechnoType) processed in TechnoExt::OnEarlyUpdate.
  • Centralized status transfer during deploy/undeploy (mind control, shields, invulnerability, attached effects, multipliers, etc.) via TechnoExt::SyncStatus.
  • Added deploy feedback improvements and documented the new conversion behaviors (including zh_CN locale updates and credits/changelog entries).

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Misc/Hooks.BugFixes.cpp Switches deploy-to-fire checks to TechnoExt::CanDeployIntoBuilding.
src/Ext/Unit/Hooks.DeploysInto.cpp Uses TechnoExt::SyncStatus, adds UndeploysInto.ConvertTo deferral, adds deploy action hook, adjusts deploy placement/desync logic.
src/Ext/Unit/Hooks.DeployFire.cpp Adds NoDeploy feedback (EVA) when Convert.Deploy targets a building without sufficient space.
src/Ext/Unit/Body.h Removes UnitExt deployer/static deploy checks now moved into TechnoExt.
src/Ext/Unit/Body.cpp Removes UnitExt::Deployer and UnitExt::CanDeployIntoBuilding implementation.
src/Ext/Techno/Body.Update.cpp Processes deferred conversions (PendingConvertTechnoType) during early update.
src/Ext/Techno/Body.h Adds PendingConvertTechnoType, Deployer, and new conversion/status-transfer method declarations.
src/Ext/Techno/Body.cpp Implements SyncStatus, moves deploy-related helpers into TechnoExt, and adds ConvertToTypeEx for cross-category conversions.
src/Ext/BuildingType/Body.h Adds UndeploysInto_ConvertTo storage and declares a helper for deploy cell computation.
src/Ext/BuildingType/Body.cpp Implements GetDeployBuildingTopLeftCell, reads/serializes UndeploysInto.ConvertTo.
docs/Whats-New.md Adds changelog entries for cross-category conversion and related improvements.
docs/New-or-Enhanced-Logics.md Documents UndeploysInto.ConvertTo.
docs/Fixed-or-Improved-Logics.md Updates “fixed/improved” notes for conversion behavior and feedback.
docs/locale/zh_CN/LC_MESSAGES/Whats-New.po Adds zh_CN translations for new changelog bullets.
docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po Adds zh_CN translations for UndeploysInto.ConvertTo docs.
docs/locale/zh_CN/LC_MESSAGES/Fixed-or-Improved-Logics.po Updates zh_CN translations to match new conversion/feedback entries.
docs/locale/zh_CN/LC_MESSAGES/CREDITS.po Adds zh_CN credits entries for the contributor.
CREDITS.md Adds credits entries for the new conversion features and preservation behaviors.
Suppressed comments (3)

src/Ext/Techno/Body.cpp:526

  • ConvertToTypeEx calls SyncStatus (which can transfer mind control, shields, attached effects, etc.) before ForceCreate. If ForceCreate fails, the source unit's state may already have been mutated (e.g., mind control freed), leaving it in an inconsistent state.
		SyncStatus(pThis, pBuilding);

		pBuilding->QueueMission(Mission::Construction, false);
		pBuilding->NextMission();

src/Ext/Techno/Body.cpp:576

  • ConvertToTypeEx calls SyncStatus before attempting Unlimbo the new unit. If Unlimbo fails, the rollback path re-unlimbos the old unit but does not restore any state already transferred (mind control, attached effects, etc.). Move status transfer until after the new unit has been successfully placed.
		if (auto const pUnit = static_cast<FootClass*>(pToType->CreateObject(pHouse)))
		{
			SyncStatus(pThis, pUnit);

			// Remove old techno from map
			pThis->Limbo();

src/Ext/Techno/Body.cpp:568

  • PR description says cross-category conversion should not support AircraftType (only same-type in-place conversion). ConvertToTypeEx currently includes AbstractType::AircraftType in the cross-type object-replacement path, which contradicts that behavior.
	case AbstractType::InfantryType:
	case AbstractType::UnitType:
	case AbstractType::AircraftType:

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Unit/Hooks.DeploysInto.cpp
Comment thread src/Ext/Unit/Hooks.DeploysInto.cpp Outdated
@frg2089
frg2089 force-pushed the develop branch 2 times, most recently from 93a4943 to 1e729ed Compare August 25, 2026 10:01
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp
Conversion was limited to types of the same class, and cross-class changes had to go through
Ares. TechnoExt::ConvertToType now handles every combination: it creates the target object,
hands over what can be carried across classes (target, destination, occupants, deploy state and
the whole TechnoExt status including attached effects, shields and mind control), places the new
object and unlinks the source.

The conversion is split into two steps so callers can ask before anything is created:

* TechnoExt::CanConvertToType does the checks without any side effect - both types have to
  differ, a building source must not be busy with its own mission, and a building target needs
  its whole foundation free where the source stands.
* TechnoExt::ConvertToType performs the conversion and runs the same check again, so no caller
  can bypass it. A failed check no longer leaves a half-created object behind.

Building placement is shared with the deploy checks: TechnoExt::CanCreateBuildingHere computes
the top-left cell of the foundation and asks CanCreateHere while FootExt::Deployer marks the
source, which FootExt::CanDeployIntoBuilding now reuses instead of duplicating it.

ConvertToType_Phobos, the Ares converter bridge, TypeConvertGroup, the warhead Convert.Apply
pair and the auto-convert actions all take a TechnoClass now, so buildings can be converted
too; HealthAutoConvertActions moved from FootExt to TechnoExt for the same reason.

Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
… type

An infantry stands on one of the sub-positions of its cell, but the object it turns into belongs
on the centre of that cell. A conversion that an infantry orders itself to do (Convert.Deploy /
Convert.Undeploy) therefore walks it there first instead of converting it on the spot; infantry
targets keep the sub-position, as the new infantry simply takes over.

The walk belongs to the deploy path, not to the conversion itself: the Mission_Unload and the
DoingAI deploy hooks start it through InfantryExt::PrepareConvertAtCellCenter and
InfantryExt::HandlePendingConvertToTypeAtCenter finishes the conversion once the infantry has
arrived.

CellClass::FindInfantrySubposition never yields the centre on its own - index 0 is unreachable
and the selection logic always rewrites it into 2..4 - so CellExt::InfantryCenterAllowed lets
the hook in Ext/Cell/Hooks.cpp force the centre entry while the infantry walks. Plain MoveTo
cannot do the hop: the walk AI drops any destination inside the infantry's own cell as "already
arrived" and the order is silently lost.

The spot is checked again on arrival: if another object has taken it in the meantime the
conversion fails instead of stacking two objects on one cell, and the pending conversion is
dropped so the cell's centre flag is released again.

Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
[SomeBuilding] -> Convert.ShowBuildUp (default false) decides whether a conversion into or out of
this building plays the buildup animation and its BuildingSlam sound. Buildings that should
appear instantly when another object is converted into them - or that should disappear without
the animation when they are converted away - can set it to no.

Only conversions are affected. Regular DeploysInto / UndeploysInto deploys do not go through the
conversion code and keep playing the buildup.

Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
- Add "Convert TechnoType into any other type" section describing
  conversions across categories and to/from BuildingTypes, the new
  Convert.ShowBuildup / Convert.ShowBuildupFrom / Convert.ShowBuildupTo
  and Convert.Direction tags
- Document Convert.Health.AfterBuildup, drop the outdated "does not
  support BuildingTypes" warnings (4x), note that Convert.Deploy /
  Convert.Undeploy accept any TechnoType and that infantry walks to the
  cell centre before converting
- Add Whats-New 0.6 and CREDITS entries, plus zh_CN translations

Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs testing ⚙️T1 T1 maintainer review is sufficient

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants